class Person {
    // 私有属性：属性前面会加_
    private _name: string
    private _age: number

    constructor(name: string, age: number) {
        this._name = name
        this._age = age
    }

    running() {
        console.log("running", this._name)
    }

    // setter/getter
    set name(newValue: string) {
        this._name = newValue
    }
    get name(): string {
        return this._name
    }

    set age(newValue: number) {
        if (newValue >= 0 && newValue < 200) {
            this._age = newValue
        }
    }

    get age(): number {
        return this._age
    }
}

const p = new Person("why", 100)

p.name = "baki"
p.running()
console.log(p.name)

p.age = -10
console.log(p.age)


export { }